{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "26f5616c",
   "metadata": {},
   "source": [
    "* 本学习记录人：莫金婵\n",
    "* 学习时间：2021-12-15\n",
    "* week11（week16）\n",
    "* [参考文档](https://www.python.org/doc/)\n",
    "* [博客](https://www.cnblogs.com/xuzhichao)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efc62ea8",
   "metadata": {},
   "source": [
    "* 项目的核心知识点：\n",
    "> 1. Flask角色定位：中央登记中心\n",
    ">> 1. 路由：\n",
    ">> 1. url 相对路径（不完整路径）：相对于 https://127.0.0.1:5000 的相对路径\n",
    ">>>2.HTTP方法：【GET默认】【POST有用户输入】"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "b8202007",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method route in module flask.app:\n",
      "\n",
      "route(rule, **options) method of flask.app.Flask instance\n",
      "    A decorator that is used to register a view function for a\n",
      "    given URL rule.  This does the same thing as :meth:`add_url_rule`\n",
      "    but is intended for decorator usage::\n",
      "    \n",
      "        @app.route('/')\n",
      "        def index():\n",
      "            return 'Hello World'\n",
      "    \n",
      "    For more information refer to :ref:`url-route-registrations`.\n",
      "    \n",
      "    :param rule: the URL rule as string\n",
      "    :param endpoint: the endpoint for the registered URL rule.  Flask\n",
      "                     itself assumes the name of the view function as\n",
      "                     endpoint\n",
      "    :param options: the options to be forwarded to the underlying\n",
      "                    :class:`~werkzeug.routing.Rule` object.  A change\n",
      "                    to Werkzeug is handling of method options.  methods\n",
      "                    is a list of methods this rule should be limited\n",
      "                    to (``GET``, ``POST`` etc.).  By default a rule\n",
      "                    just listens for ``GET`` (and implicitly ``HEAD``).\n",
      "                    Starting with Flask 0.6, ``OPTIONS`` is implicitly\n",
      "                    added and handled by the standard request handling.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(app.route)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6853b87e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " * Serving Flask app \"__main__\" (lazy loading)\n",
      " * Environment: production\n",
      "   WARNING: This is a development server. Do not use it in a production deployment.\n",
      "   Use a production WSGI server instead.\n",
      " * Debug mode: off\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n"
     ]
    }
   ],
   "source": [
    "from flask import Flask,request\n",
    "from flask import render_template\n",
    "\n",
    "app = Flask(__name__)\n",
    "\n",
    "@app.route(\"/\",methods=['GET'])\n",
    "def hello_words():\n",
    "    return render_template('hello.html')                   \n",
    "\n",
    "@app.route(\"/index\",methods=['GET'])    \n",
    "def index():\n",
    "    return render_template('index.html')            \n",
    "\n",
    "@app.route(\"/result\",methods=['POST'])            \n",
    "def result():\n",
    "    \n",
    "    py_firstname = requst.form['firstname']\n",
    "    py_lastname = requst.form['lastname']\n",
    "    py_fullname = py_firstname.title() + ' ' + py_lastname.title()\n",
    "    return render_template('result.html',\n",
    "                          fullname = py_fullname)\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    app.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04cd3be9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14489dcc",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
